from django.contrib.auth.models import Permission
from django.contrib.contenttypes.models import ContentType
from rest_framework.permissions import IsAdminUser
from rest_framework.viewsets import ModelViewSet
from rest_framework.response import Response

from meiduo_admin.serialziers.permissions import PermissionSerializer, ContentTypeSerializer
from meiduo_admin.utils import PageNum


class PermissionsView(ModelViewSet):
    serializer_class = PermissionSerializer
    queryset = Permission.objects.all()
    # 分页
    pagination_class = PageNum
    permission_classes = [IsAdminUser]

    def content_type(self,request):
        data =ContentType.objects.all()

        ser = ContentTypeSerializer(data,many=True)

        return Response(ser.data)


